
<?php

defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$uniacid = $_SESSION['uniacid'];
$mid = $_SESSION['uid'];
$basic=$this->plugin_setting('basic');
$return['advs']=$basic['image'];
$return['setting']=$basic;
if($_RQ['op']=='main'){
	/*******main*******/
	$return['category']=pdo_getall('jy_sendgoods_category',array('uniacid'=>$_SESSION['uniacid'],'status'=>1));
	exi($return);
}
if($_RQ['op']=='getlist'){
	//首页热门活动
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'ishot'=>1);
	$type=intval($_RQ['type']);
	if($type=='2'){
		$params['starttime >']=time();
		$return['status']=2;
	}else{
		$params['starttime <']=time();
		$params['endtime >']=time();
		$return['status']=1;
	}
	$fields=array('id','uniacid','title','status','goodsid','sales','image','starttime','endtime','ishot','displayorder','createtime');
	$list=pdo_getslice('jy_sendgoods_act',$params,array($pindex,$psize),$total,$fields,'','displayorder desc');
	$acts_count=count($list);
	if($list){
		foreach($list as &$item){
			$goods=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['goodsid']));
			$item['image']=tomedia($goods['image']);
			$item['goods']=$goods;
		}
	}
	
	//print_r($groups);exit;
	$return['list']=$list;
	$return['acts_count']=$acts_count;
	exi($return);
}